<?php
    header("Content-type:text/html;charset=utf-8");

    //接受前端的数据
    $username=$_POST["username"];
    $password=$_POST["password"];
    // 建立链接
    $con=mysql_connect("localhost","root","123456");
   
    //选择数据库
    mysql_select_db("xiaozi");
    mysql_query("set character set 'utf8'");//读库
    mysql_query("set names 'utf8'");//写库
    //查询
    $result=mysql_query("select * from user where username='$username' and password='$password'",$con);

    //获得$result的行数
    $rows=mysql_num_rows($result);

    //向前端返回数据
    if($rows>0){
        echo "success";
    }
    else{
        echo "erro";
    }
    //关闭连接
    mysql_close($con);
   
?>